package com.xinghou.mq.consumer;

import java.util.Arrays;
import java.util.List;

import com.aliyun.openservices.ons.api.Consumer;
import com.aliyun.openservices.ons.api.ONSFactory;
import com.xinghou.mq.*;
import com.xinghou.platform.server.mq.MqMessage;
import org.slf4j.Logger;

public class StartAll {
    private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(AbstractConsumer.class);
    private IConsumer iConsumer;

    public static void main(String[] args) {
        logger.info("start------------------------");
        ApplicationContext ac = ApplicationContext.getContext();
        MqConfig mc = MqConfig.getByArgs(args);
        Consumer consumer = ONSFactory.createConsumer(mc.getProperties());
        IConsumer iConsumer = ac.getBean(IConsumer.class);
        ConsumerUtil.subscribe(mc.getTopics(), consumer, iConsumer);
        consumer.start();
        logger.info("end------------------------");

    }


}
